
                            READ_FB.TXT
                README file for FANUC LADDER LIBRARY

            (C) Copyright FANUC CORPORATION, 2000-2012, All Rights Reserved.

This document provides the information about "Sample file of FUNCTION
BLOCK LIBRARY".
Please read this document before using the Sample file.

--------------------------------------------------------------------------
[1] Introduction
[2] File summary
[3] Condition
[4] How to use FB definition
[5] FB definition list and function explanation
--------------------------------------------------------------------------


==========================================================================
[1] Introduction
==========================================================================

The Function Block library is a library file that collected the Function
Block definitions (Abbreviation: FB definition).
The FB library can be used by the ladder program that selects the Function
Block function. Moreover, the FB definition in Function Block library
(FBSample.FLL ) can be modified, and new FB definitions can be added.

--------------------------------------------------------------------------
[1.1 Note]
--------------------------------------------------------------------------
These sample FLL files are provided in order to illustrate how to create,
edit, and utilize a Function Block.  Please confirm carefully that the
sequence program works without problem before you make them work actually.

--------------------------------------------------------------------------
[1.2 History]
--------------------------------------------------------------------------
01.0
 - New registration


==========================================================================
[2] File summary
==========================================================================

The sample programs are stored in the following folder of installation CD-ROM.

(CD-ROM drive name):\Tool\FB\Window

  FBSample.FLL : Function Block library file
  Read_FB.TXT  : English document
  ReadJ_FB.TXT : Japanese document


==========================================================================
[3] Application condition
==========================================================================

Software
 - FANUC LADDER-III Ver5.60 or later

CNC Option
 - Function Block function
 Required to run the ladder program with FB on CNC

This sample program (FBSample.FLL) can be used in CNC listed below. 
 - Series 30i/31i/32i-Model A
 - Series 0i/0i Mate-Model D
 - Series 30i/31i/32i/35i-Model B
 - Power Motion i-Model A


==========================================================================
[4] How to use FB definition
==========================================================================

  4.1 Creating of LAD file

      (1) Start up FANUC LADDER-III.

      (2) Click [New Program...] in [File] menu.
          Enter LAD file name into [Name] and select [PMC Type] in New Program screen.
          For example
             PMC Type : 30i-A PMC
             PMC Path : 1st Path
             Select the [Function Block]
          Push the <OK> button.

  4.2 Setting of FB library

      (1) Click [Option...] in [Tool] menu.
          Click [Function Block] tab in the Option screen.

      (2) Push <Detail...> button in [Setting of Function Block Library]

      (3) Push <Browse...> button, then open FBSample.FLL file.

      (4) Push <OK> button.
          FB definitions in FBSample.FLL are displayed under
          [Function Block Library] in Program List screen.

  4.3 Integrating FB definition into ladder program

      (1) Open a subprogram, such as LEVEL2 in the program list.

      (2) Drag the FB definition to use, and drop to LEVEL2.
          Or, enter FB definition name on LEVEL2, and press F9 key.
          Enter FB instance name, and push <Add> button.

      (3) Program the input/output section of the FB instance, placing
          relays with address properly according to the FB definition.
          See the explanation of the FB definition for more details.

  4.4 Setting of assignment address of FB

      (1) Double click [System parameter] in [Program List].

      (2) Push <Assignment Address of FB> button in the Edit System
          Parameter screen.

      (3) Enter Start/End addresses of FB variable, and ones of FB
          variable (keep). The specified addresses should not be used
          by the ladder program.

  4.5 Compiling ladder program

      (1) Click [Compile...] in [Tool] menu.

      (2) Push <Exec> button in the Compile screen.

  4.6 Store the ladder program into CNC

      Store the compiled ladder program by online function, or via
      the memory card format file.


==========================================================================
[5] FB definition list and function explanation
==========================================================================

FBSample.FLL has the following FB definitions.

FB definition list            Explanation

 5.1  FA001_WINDR_SINT_high   Window reading of 1 byte data(high-speed response)

 5.2  FA002_WINDR_INT_high    Window reading of 2 byte data(high-speed response)

 5.3  FA003_WINDR_DINT_high   Window reading of 4 byte data(high-speed response)

 5.4  FA004_WINDR_SINT_low    Window reading of 1 byte data(low-speed response)

 5.5  FA005_WINDR_INT_low     Window reading of 2 byte data(low-speed response)

 5.6  FA006_WINDR_DINT_low    Window reading of 4 byte data(low-speed response)

 5.7  FA011_WINDW_SINT_low    Window writing of 1 byte data(low-speed response)

 5.8  FA012_WINDW_INT_low     Window writing of 2 byte data(low-speed response)

 5.9  FA013_WINDW_DINT_low    Window writing of 4 byte data(low-speed response)


Function explanation

-----------------------------------------------------------------------------
5.1 FA001_WINDR_SINT_high : Window reading of 1 byte data(high-speed response)
5.2 FA002_WINDR_INT_high  : Window reading of 2 byte data(high-speed response)
5.3 FA003_WINDR_DINT_high : Window reading of 4 byte data(high-speed response)
-----------------------------------------------------------------------------

  1/2/4 byte data of CNC is read by using the WINDR instruction. The window
  reading of the function code of high-speed response is possible, and the
  Data after FB is executed can be used immediately. 
  When an error occurs, ErrBit is turned on.
  Use the FB definition of the same size as the read data size. 

  FB Graphical Form
            .----------------------------------.
            |       FA001_WINDR_SINT_high      |
            |                                  |
      BOOL -*ACT                            ENO*- BOOL
            |                                  |
       INT -*FuncNum                     ErrBit*- BOOL
            |                                  |
       INT -*Path                          Data*- SINT
            |                                  |
       INT -*Num                               |
            |                                  |
       INT -*Attr                              |
            |                                  |
            .----------------------------------.

            .----------------------------------.
            |       FA002_WINDR_INT_high       |
            |                                  |
      BOOL -*ACT                            ENO*- BOOL
            |                                  |
       INT -*FuncNum                     ErrBit*- BOOL
            |                                  |
       INT -*Path                          Data*- INT
            |                                  |
       INT -*Num                               |
            |                                  |
       INT -*Attr                              |
            |                                  |
            .----------------------------------.

            .----------------------------------.
            |       FA003_WINDR_DINT_high      |
            |                                  |
      BOOL -*ACT                            ENO*- BOOL
            |                                  |
       INT -*FuncNum                     ErrBit*- BOOL
            |                                  |
       INT -*Path                          Data*- DINT
            |                                  |
       INT -*Num                               |
            |                                  |
       INT -*Attr                              |
            |                                  |
            .----------------------------------.

  Input parameter
    ACT     : The execution of the Function Block is controlled.
              When ACT=1, the FB body program is executed.
              When ACT=0, the FB body program is not executed.
    FnucNum : Set the function code of the window function.
    Path    : Set the CNC path number.
    Num     : Set the data number.
    Attr    : Set the data attribute.

  Output parameter
    ENO     : When the execution of the Function Block has been completed, 
              ENO is turned on. When ACT turns off, ENO is turned off, too. 
    ErrBit  : When ErrBit=1, an error occurs.
    Data    : When ENO=1 and ErrBit=OFF, the data is output.

  FB instance monitoring
    ErrCode : The completion code of the window instruction is displayed. 


  For example, the following window functions can be used.
   - [13]  Reading a tool offset
   - [15]  Reading a work piece origin offset value (A specific axis)
   - [17]  Reading a parameter (A specific axis)
   - [19]  Reading setting data (A specific axis)
   - [27]  Reading the absolute position (absolute coordinates) of controlled axes (A specific axis)
   - [28]  Reading the machine position (machine coordinates) of controlled axes (A specific axis)
   - [74]  Reading the relative position on a controlled axis (A specific axis)
   - [428] Reading the actual machine position of controlled axes (A specific axis)
   etc.

  Remarks
    The window function that all the following conditions apply can be used. 
      - The data area of the window instruction is in the 10th byte.
      - Data length is 1, 2, and 4. 
      - Reading of high-speed response


  Example: Ladder to read No.24 of CNC parameter

       |                         FA001_WINDR_SINT_high_1                        |
       |                  .----------------------------------.                  |
       |                  |       FA001_WINDR_SINT_high      |                  |
       | R0000.0          |                                  |          R0000.1 |
       *----||------------*ACT                            ENO*-------------()---*
       |                  |                                  |          R0000.7 |
       |               17-*FuncNum                     ErrBit*-------------()---*
       |                  |                                  |                  |
       |                1-*Path                          Data*-R0004            |
       |                  |                                  |                  |
       |               24-*Num                               |                  |
       |                  |                                  |                  |
       |                0-*Attr                              |                  |
       |                  |                                  |                  |
       |                  .----------------------------------.                  |

      When R0.0=1, R0.1=1 and the value of No.24 of the CNC parameter is
      output to R4.


-----------------------------------------------------------------------------
5.4 FA004_WINDR_SINT_low  : Window reading of 1 byte data(low-speed response)
5.5 FA005_WINDR_INT_low   : Window reading of 2 byte data(low-speed response)
5.6 FA006_WINDR_DINT_low  : Window reading of 4 byte data(low-speed response)
-----------------------------------------------------------------------------

  1/2/4 byte data of CNC is read by using the WINDR instruction. The window
  reading of the function code of a low-speed response is possible. Keep ACT
  until ENO is turned on. Use the Data after turning on ENO. 
  When an error occurs, ErrBit is turned on.
  Use the FB definition of the same size as the read data size. 

  FB Graphical Form
            .----------------------------------.
            |       FA004_WINDR_SINT_low       |
            |                                  |
      BOOL -*ACT                            ENO*- BOOL
            |                                  |
       INT -*FuncNum                     ErrBit*- BOOL
            |                                  |
       INT -*Path                          Data*- SINT
            |                                  |
       INT -*Num                               |
            |                                  |
       INT -*Attr                              |
            |                                  |
            .----------------------------------.

            .----------------------------------.
            |       FA005_WINDR_INT_low        |
            |                                  |
      BOOL -*ACT                            ENO*- BOOL
            |                                  |
       INT -*FuncNum                     ErrBit*- BOOL
            |                                  |
       INT -*Path                          Data*- INT
            |                                  |
       INT -*Num                               |
            |                                  |
       INT -*Attr                              |
            |                                  |
            .----------------------------------.

            .----------------------------------.
            |       FA006_WINDR_DINT_low       |
            |                                  |
      BOOL -*ACT                            ENO*- BOOL
            |                                  |
       INT -*FuncNum                     ErrBit*- BOOL
            |                                  |
       INT -*Path                          Data*- DINT
            |                                  |
       INT -*Num                               |
            |                                  |
       INT -*Attr                              |
            |                                  |
            .----------------------------------.

  Input parameter
    ACT     : The execution of the Function Block is controlled.
              When ACT=1, the FB body program is executed.
              When ACT=0, the FB body program is not executed.
    FnucNum : Set the function code of the window function.
    Path    : Set the CNC path number.
    Num     : Set the data number.
    Attr    : Set the data attribute.

  Output parameter
    ENO     : When the execution of the Function Block has been completed, 
              ENO is turned on. When ACT turns off, ENO is turned off, too. 
    ErrBit  : When ErrBit=1, an error occurs.
    Data    : When ENO=1 and ErrBit=OFF, the data is output.

  FB instance monitoring
    ErrCode : The completion code of the window instruction is displayed. 


  For example, the following window functions can be used.
   - [33]  Reading diagnosis data (A specific axis)
   etc.

  Remarks
    The window function that all the following conditions apply can be used. 
      - The data area of the window instruction is in the 10th byte.
      - Data length is 1, 2, and 4. 
      - Reading of low-speed response


  Example: Ladder to read No.560 of diagnosis data

       |                         FA004_WINDR_SINT_low_1                         |
       |                  .----------------------------------.                  |
       |                  |       FA004_WINDR_SINT_low       |                  |
       | R0000.0          |                                  |          R0000.1 |
       *----||------------*ACT                            ENO*-------------()---|
       |                  |                                  |          R0000.7 |
       |               33-*FuncNum                     ErrBit*-------------()---*
       |                  |                                  |                  |
       |                1-*Path                          Data*-R0004            |
       |                  |                                  |                  |
       |              560-*Num                               |                  |
       |                  |                                  |                  |
       |                0-*Attr                              |                  |
       |                  |                                  |                  |
       |                  .----------------------------------.                  |

      When R0.0=1 and R0.1=1, the value of No.560 of the diagnosis data is
      output to R4.


-----------------------------------------------------------------------------
5.7 FA011_WINDW_SINT_low  : Window writing of 1 byte data(low-speed response)
5.8 FA012_WINDW_INT_low   : Window writing of 2 byte data(low-speed response)
5.9 FA013_WINDW_DINT_low  : Window writing of 4 byte data(low-speed response)
-----------------------------------------------------------------------------

  1/2/4 byte data of CNC is written by using the WINDW instruction. The window 
  writing of the function code of a low-speed response is possible. Keep ACT
  until ENO or ErrBit is turned on. When an error occurs, ErrBit is turned on.
  Use the FB definition of the same size as the write data size. 

  FB Graphical Form
            .---------------------------------.
            |      FA011_WINDW_SINT_low       |
            |                                 |
      BOOL -*ACT                           ENO*- BOOL
            |                                 |
       INT -*FuncNum                    ErrBit*- BOOL
            |                                 |
       INT -*Path                             |
            |                                 |
       INT -*Num                              |
            |                                 |
       INT -*Attr                             |
            |                                 |
      SINT -*Data                             |
            |                                 |
            .---------------------------------.

            .---------------------------------.
            |      FA012_WINDW_INT_low        |
            |                                 |
      BOOL -*ACT                           ENO*- BOOL
            |                                 |
       INT -*FuncNum                    ErrBit*- BOOL
            |                                 |
       INT -*Path                             |
            |                                 |
       INT -*Num                              |
            |                                 |
       INT -*Attr                             |
            |                                 |
       INT -*Data                             |
            |                                 |
            .---------------------------------.

            .---------------------------------.
            |      FA013_WINDW_DINT_low       |
            |                                 |
      BOOL -*ACT                           ENO*- BOOL
            |                                 |
       INT -*FuncNum                    ErrBit*- BOOL
            |                                 |
       INT -*Path                             |
            |                                 |
       INT -*Num                              |
            |                                 |
       INT -*Attr                             |
            |                                 |
      DINT -*Data                             |
            |                                 |
            .---------------------------------.

  Input parameter
    ACT     : The execution of the Function Block is controlled.
              When ACT=1, the FB body program is executed.
              When ACT=0, the FB body program is not executed.
    FnucNum : Set the function code of the window function.
    Path    : Set the CNC path number.
    Num     : Set the data number.
    Attr    : Set the data attribute.
    Data    : Set the written data.

  Output parameter
    ENO     : When the execution of the Function Block has been completed, 
              ENO is turned on. When ACT turns off, ENO is turned off, too. 
    ErrBit  : When ErrBit=1, an error occurs.

  FB instance monitoring
    ErrCode : The completion code of the window instruction is displayed. 


  The following window functions can be used.
   - [14]  Writing a tool offset
   - [16]  Writing a work piece origin offset value (A specific axis)
   - [18]  Writing a parameter (A specific axis)
   - [20]  Writing setting data (A specific axis)
   - [249] Presetting the relative coordinate
   etc.

  Remarks
    The window function that all the following conditions apply can be used. 
      - The data area of the window instruction is in the 10th byte.
      - Data length is 1, 2, and 4. 
      - Writing of high-speed response


  Example: Ladder to write data to No.21 of CNC parameter
       |                         FA011_WINDW_SINT_low_1                         |
       |                   .---------------------------------.                  |
       |                   |      FA011_WINDW_SINT_low       |                  |
       | R0000.0           |                                 |          R0000.1 |
       *----||-------------*ACT                           ENO*-------------()---*
       |                   |                                 |          R0000.7 |
       |               18--*FuncNum                    ErrBit*-------------()---*
       |                   |                                 |                  |
       |                1--*Path                             |                  |
       |                   |                                 |                  |
       |               21--*Num                              |                  |
       |                   |                                 |                  |
       |                0--*Attr                             |                  |
       |                   |                                 |                  |
       |               11--*Data                             |                  |
       |                   |                                 |                  |
       |                   .---------------------------------.                  |

      When R0.0=1 and R0.1=1, 11 is written to No.21 of CNC parameter.


